package pro.softzhang.algo.lc200;

public class LC242_ValidAnagram {
    public static void main(String[] args) {
        String a  = "a";
        String b = "a";
        boolean f = new Solution().isAnagram(a, b);
        System.out.println(f);
    }

    static class Solution {
        public boolean isAnagram(String s, String t) {
            if(s.length() != t.length() || s.equals(t)) {
                return false;
            }

            int[] stat = new int[26];
            for (char c : s.toCharArray()) {
                stat[c - 'a']++;
            }

            for (char c : t.toCharArray()) {
                if(stat[c - 'a'] == 0) {
                    return false;
                }
                stat[c - 'a']--;
            }
            return true;
        }
    }
}
